import java.util.Scanner;

import static java.lang.Math.pow;

public class Test2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        for(int i = 1; i < n; i++){
            int count = 0;
            int i1 = i;
            while(i1 != 0){
                i1 /= 10;
                count++;
            }
            int sum = 0;
            int i2 = i;
            while(count-- != 0){
                sum += (i2 % 10)*(i2 % 10)*(i2 % 10);
                i2 /= 10;
            }
            if(sum == i){
                System.out.println(i);
            }
        }
    }
}
